/*
 * @Description  :
 * @Version      : 1.0
 * @Author       : Shiming
 * @Date         : 2022-03-10 14:50:45
 * @LastEditors  : Shiming
 * @LastEditTime : 2022-05-12 17:54:15
 * @FilePath     : \\tms-obc-web\\src\\app\\routes\\partner\\rebate-management\\model\\abnormal-feedback\\abnormal-feedback.component.ts
 * Copyright (C) 2022 huzhenhong. All rights reserved.
 */
import { Component, OnInit, ViewChild } from '@angular/core';
import { SFComponent, SFSchema, SFTextareaWidgetSchema, SFUISchema } from '@delon/form';
import { ShipperBaseService } from '@shared';
import { NzModalRef } from 'ng-zorro-antd/modal';
import { RebateManagementService } from '../../services/rebate-management.service';

@Component({
  selector: 'app-parter-channel-rebate-management-abnormal-feedback',
  templateUrl: './abnormal-feedback.component.html'
})
export class ParterRebateManageMenAbnormalFeedbackComponent implements OnInit {
  schema: SFSchema = {};
  ui!: SFUISchema;
  @ViewChild('sf', { static: false })
  sf!: SFComponent;
  i!: any;
  mybidDetailInfo: any = [];
  data = [{ name1: 1111 }];
  constructor(public service: RebateManagementService, public shipperservice: ShipperBaseService, public modalRef: NzModalRef) {}

  ngOnInit() {
    this.initSF();
    this.initData();
  }
  initData() {
    if (this.i) {
      console.log(this.i);

      this.service
        .request(this.service.$api_get_getExceptionMessage, { partnerId: this.i?.partnerId, month: this.i.month, year: this.i.year })
        .subscribe(res => {
          console.log(res);
          this.mybidDetailInfo = res;
        });
    }
  }
  initSF() {
    this.schema = {
      properties: {
        feedbackInfo: {
          type: 'string',
          title: '回复',
          maxLength: 50,
          ui: {
            widget: 'textarea',
            autosize: { minRows: 3, maxRows: 6 },
            placeholder: '请不要超过50个字'
          } as SFTextareaWidgetSchema
        }
      }
    };
    this.ui = {
      '*': {
        spanLabelFixed: 60,
        grid: { span: 16 }
      }
    };
  }
  close() {
    if (!this.sf.valid) {
      this.service.msgSrv.error('请填写必填项！');
      return;
    }
    let params = {
      partnerId: this.i?.partnerId,
      month: this.i.month,
      year: this.i.year,
      ...this.sf.value
    };
    this.service.request(this.service.$api_get_partnerIncomeExceptionAdd,params).subscribe((res) => {
      if(res) {
      this.service.msgSrv.success('保存成功！');
        this.modalRef.destroy();
      }
    })
  }
}
